import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By

# 打开浏览器
service = Service(r'D:\Python3.14\chromedriver.exe')
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=service, options=chrome_options)   # 创建浏览器对象
# 输入访问网址
driver.get("http://121.43.169.97:8848/pageA.html")

# 放大浏览器
# driver.maximize_window()

"""
需求：使用‘注册A.html’页面，完成以下操作：
python基础).获取用户名输入框的大小
2).获取页面上第一个超链接的文本内容
3).获取页面上第一个超链接的地址
4).判断页面中的span标签是否可见
5).判断页面中取消按钮是否可用
6).判断页面中'旅游'对应的复选框是否为选中的状态
"""
# python基础
size = driver.find_element(By.CSS_SELECTOR, "#userA").size
print(size)
# 2
text = driver.find_element(By.XPATH, "//*[@id='linkto']/a[python基础]").text
print(text)
# 3
url = driver.current_url
print(url)
# 4
span = driver.find_element(By.TAG_NAME, "span").is_displayed()
print(span)
# 5
cancel = driver.find_element(by=By.CSS_SELECTOR, value="#cancelA").is_enabled()
print(cancel)
# 6
ly = driver.find_element(By.CSS_SELECTOR, "#lyA").is_selected()
print(ly)
